package ac.svn.accesscontrol.ui.helper.formatter;

import ac.svn.accesscontrol.store.SVNGroup;
import ac.svn.accesscontrol.store.SVNUser;
import ac.svn.accesscontrol.ui.IListItemTextFormatter;

public class AccessUnitOwnerNameFormatter implements IListItemTextFormatter {

    @Override
    public String formatString(Object msgObj) 
    {
	String title = "";
	if(msgObj instanceof SVNUser)
	{
	    SVNUser user = (SVNUser) msgObj;
	    title = String.format("<HTML>[<b>User</b>] %s</HTML>",user.getUserName());
	}
	else if(msgObj instanceof SVNGroup)
	{
	    SVNGroup group = (SVNGroup) msgObj;
	    title = String.format("<HTML>[<b>Group</b>]<b> %s</b></HTML>",group.getGroupName());	    
	}
	return title;
    }

    @Override
    public String formatToolTip(Object msgObject) {
	
	String toolTip = "";
	if(msgObject instanceof SVNUser)
	{
	    SVNUser user = (SVNUser) msgObject;
	    toolTip = user.getTooltipText();	
	}
	else if(msgObject instanceof SVNGroup)
	{
	    SVNGroup group = (SVNGroup) msgObject;
	    toolTip = group.getTooltipText();	    
	}
	return toolTip;
    }

}
